package animix.blue.server.user.mapper;

import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.jdbc.SQL;

import java.util.Map;

public class RightProvider {

    public String list(Map<String, Object> para) {
        return new SQL() {{
            SELECT("*");
            FROM("tb_right");
            if (StringUtils.isNotBlank((String) para.get("sorter"))) {
                String[] sorter = ((String) para.get("sorter")).split("_");
                ORDER_BY(sorter[1].equals("descend") ? sorter[0] + " DESC" : sorter[0] + " ASC");
            }
        }}.toString();
    }
}
